import VueRouter from "vue-router"

import Vue from "vue"

import Login from '@/pages/Login/login'
import Home from '@/pages/Home/home'
import Music from "@/pages/Home/Music"
import Games from "@/pages/Home/Games"

Vue.use(VueRouter)

export default new VueRouter({
    routes:[
        {
            path:'/login',
            component:Login,
            name:'login'
        },
        {
            path:'/home',
            component:Home,
            // 默认子路由
            // redirect:'/home/music',
            children:[
                {
                    //可选传参
                    path:"music/:id?",
                    component:Music,
                    name:"music",
                    // 开启props,可以通过props拿到params传参
                    props:true
                },
                {
                    path:"games/:id?",
                    component:Games,
                    name:"games",
                    props(route){
                        console.log(route);
                        return route.query
                    }
                },
            ]
        }
    ]
})